package com.cxf.windex.rest.admin;

import com.cxf.windex.base.msg.ObjectRestResponse;
import com.cxf.windex.base.rest.BaseRestController;
import com.cxf.windex.biz.JsUserBiz;
import com.cxf.windex.entity.JsUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @program: business_needs
 * @description: 管理用户
 * @author: chenxf
 * @create: 2018-10-09 11:42
 **/
@Api(tags = {"村广通[后台] - 用户接口"})
@Controller
@RequestMapping("admin/user")
public class AdminUserController extends
        BaseRestController<JsUserBiz, JsUser> {
    @ApiOperation(value = "后台登陆", notes = "登陆返回TOKEN")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "username", value = "用户名", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "password", value = "密码", required = true, paramType = "query", dataType = "String")
    })
    @RequestMapping(value = "/login", method = RequestMethod.POST)
    @ResponseBody
    public ObjectRestResponse adminLogin(String username, String password) {
        return new ObjectRestResponse().rel(true).msg("登陆成功").result(baseBiz.adminLogin(username,password));
    }

    @RequestMapping(value = "/pwd", method = RequestMethod.POST)
    @ResponseBody
    public ObjectRestResponse pwd(String password,String newPassword,String newPassword2){
        baseBiz.pwd(password,newPassword,newPassword2,this.getCurrentUserId());
        return  new ObjectRestResponse().rel(true).msg("修改成功");
    }
}
